﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace PPI.General
{
    /// <summary>
    /// Fill a dataTable with Id (int) ,Name(string) collumns
    /// </summary>
    public class FillSpecificDataTableHelper
    {
        /// <summary>
        /// LLena un datatable entre los valores inicial(Start)  y final (end), avanzando de a n unidades (step)
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="step"></param>
        /// <returns></returns>
        public static DataTable FillDataTable(int start, int end, int step)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("Id", typeof (Int32)));
            dt.Columns.Add(new DataColumn("Name", typeof (string)));
            int i = 1;
            while(start <= end)
            {
                dt.Rows.Add(start, start);
                start += step;
            }
            return dt;
        }

        public static DataTable FillDataTable(int idStart, int start, int end, int step)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("Id", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));

            idStart += 1;
            while (start <= end)
            {
                dt.Rows.Add(idStart++, start);
                start += step;
            }
            return dt;
        }
    }
}
